home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Collections: MegaDisc
/
MegaDisc 27 (1992-03)(MegaDisc Digital Publishing)(AU)(Disk 2 of 2).zip
/
MegaDisc 27 (1992-03)(MegaDisc Digital Publishing)(AU)(Disk 2 of 2).adf
/
Programming
/
Random
/
random.h
< prev
next >
Wrap
C/C++ Source or Header
|
1992-03-30
|
1KB
|
40 lines
/*
;------------------------------------------------------------------
; Code typed by Peter Thompson on 11 Feb. 92, although written
; several days earlier. This code is "wareware"; if you use it in
; any of your programs for which you want money, send me a copy at:
; 33 Pleasant Street/Pascoe Vale 3044/Australia
;------------------------------------------------------------------
; $MUSIC = "The Black Sorrows/Hold On To Me"
;------------------------------------------------------------------
; Algorithm adapted from "Algorithms in C", Robert Sedgewick,
; pub. Addison-Wesley 1990 (he got it from Knuth, vol. 2?)
;------------------------------------------------------------------
*/
#ifndef ULONG
typedef unsigned long int ULONG;
#endif
#define MAXRNDNUM 2147483648
typedef struct randstate {
ULONG rs_Index;
ULONG rs_State[64];
} RandState;
extern void rand32init(RandState *,ULONG);
/* Call this function to initialise to a particular sequence of random
numbers.
*/
extern ULONG rndx32(RandState *);
/* additive congruential method using exclusive-or
*/
extern ULONG rnda32(RandState *);
/* additive congruential method using addition modulo MAXRNDNUM
*/
/* The number of numbers before the sequence generated by rnda32 or rndx32
begins to repeat itself is at least 2^55-1, or more than 36028797018700000.
*/